﻿using System;
using System.Net;
using System.Windows;
using Newtonsoft.Json.Linq;

namespace Sina.Altman.Weibo.SDK.Objects
{
    public class Geos
    {
        public Geos(string json)
         : this(JObject.Parse(json))
        {
        }

        private JObject __jobject;
        public Geos(JObject obj)
        {
            this.__jobject = obj;
        }

        [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
        private Geo[] _geoItems;
        public Geo[] GeoItems
        {
            get
            {
                if (_geoItems == null)
                    _geoItems = (Geo[])JsonClassHelper.ReadArray<Geo>(JsonClassHelper.GetJToken<JArray>(__jobject, "geos"), JsonClassHelper.ReadStronglyTypedObject<Geo>, typeof(Geo[]));
                return _geoItems;
            }
        }
    }

    public class Geo
    {
        private JObject __jobject;
        public Geo(JObject obj)
        {
            this.__jobject = obj;
        }

        public string Longitude
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "longitude"));
            }
        }

        public string Latitude
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "latitude"));
            }
        }

        public string City
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "city"));
            }
        }

        public string Province
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "province"));
            }
        }

        public string CityName
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "city_name"));
            }
        }

        public string ProvinceName
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "province_name"));
            }
        }

        public string Address
        {
            get
            {
                return JsonClassHelper.ReadString(JsonClassHelper.GetJToken<JValue>(__jobject, "address"));
            }
        }
    }
}
